home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20020314-20021006 / 000386_fdc@columbia.edu_Tue Sep 24 09:29:03 EDT 2002.msg < prev    next >
Text File  |  2020-01-01  |  4KB  |  110 lines

  1. Article: 13722 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
  3. From: fdc@columbia.edu (Frank da Cruz)
  4. Newsgroups: comp.protocols.kermit.misc
  5. Subject: Re: scripting to a serial sms modem - idiot question!
  6. Date: 24 Sep 2002 09:28:51 -0400
  7. Organization: Columbia University
  8. Lines: 93
  9. Message-ID: <amppaj$rki$1@watsol.cc.columbia.edu>
  10. References: <e516d9ec.0209160537.450ca7b@posting.google.com> <am9v0g$t1e$1@watsol.cc.columbia.edu> <e516d9ec.0209190043.6a2c8e0d@posting.google.com> <e516d9ec.0209240321.7d110c63@posting.google.com>
  11. NNTP-Posting-Host: watsol.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1032874133 4272 128.59.39.139 (24 Sep 2002 13:28:53 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 24 Sep 2002 13:28:53 GMT
  15. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13722
  16.  
  17. In article <e516d9ec.0209240321.7d110c63@posting.google.com>,
  18. Mark Swarbrick <mswarbrick@rentokil.com> wrote:
  19. : I've had some more time to work on the sms project. The basic idea is
  20. : to allow someone to text commands to the sms modem eg. 'uptime' and a
  21. : text message sent back with the uptime. I've ordered the kermit book,
  22. : but could use some help in the meantime with strings.
  23. : ---------
  24. : #!/usr/bin/kermit
  25. : ; sets modem init stuff
  26. : set line /dev/ttyS0
  27. :
  28. Need IF FAIL here...
  29.  
  30. : set speed 9600
  31. : set carrier-watch off
  32. : set input echo on
  33. : lineout at
  34. : input 20 ok
  35. :
  36. Need IF FAIL...
  37.  
  38. : lineout AT+CMGF=1
  39. : input 20 ok
  40. Need IF FAIL after every INPUT...
  41.  
  42. : ; queries modem for all messages
  43. : lineout at+cmgs=?
  44. : input 20 ok
  45. : lineout at+cmgl="ALL"
  46. : input 100 ok
  47. : ; Loops msg by message extracting the number and message text into 
  48. : : two strings
  49. : ; $msg $no
  50. You have to be more specific if you want this translated into code.
  51. Exactly what is a "number" and a "message"?  Give a specific example.
  52. How do you know where the end is?
  53.  
  54. : ; Depending on the text of the message perform external command which
  55. : : includes modifying the response to fit in 160 chars eg sed / awk etc
  56. : : store the reply in a string called reply_txt
  57. :
  58. You don't need an external command for that; Kermit can do it all by
  59. itself.
  60.  
  61. : ; Execute the send message sms command using  $no and $reply_txt strings
  62. : : then loop to next message until there are no more, then delete all
  63. : : messages from the modems memory
  64. : ---------
  65. : Does this sound about right? also how to i run a command and store the
  66. : results in a string?
  67. :
  68. Again, you don't need to run external programs to manipulate strings.
  69. Kermit has a full range of string manipulation functions.  But to
  70. answer your question:
  71.  
  72.   \fcommand(command args)
  73.  
  74. runs the given command with the given string and returns its output so you
  75. can use it, e.g.
  76.  
  77.   assign foo \fcommand(uptime)
  78.   echo Uptime: \m(foo)
  79.  
  80. Type "help functions" to learn more about Kermit's built-in functions.
  81.  
  82. : in bash i'd just type uptime > uptime.txt. But
  83. : can I have a clue how to do it in kermit? Then how to i write that
  84. : string to a file?
  85. Kermit has the full range of file i/o features:
  86.  
  87.   http://www.columbia.edu/kermit/ckermit70.html#x1.22
  88.  
  89. Even though you don't have the book yet, you can learn a lot by studing
  90. the tutorial and sample scripts here:
  91.  
  92.   http://www.columbia.edu/kermit/ckscripts.html
  93.  
  94. and by reading the C-Kermit 7.0 and 8.0 release notes:
  95.  
  96.   http://www.columbia.edu/kermit/ckermit70.html
  97.   http://www.columbia.edu/kermit/ckermit80.html
  98.  
  99. - Frank
  100.